Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

651
Views
Go build: build output "api" already exists and is a directory

I am trying to use CompileDaemon to hot reload a go project using Docker.

My folder structure looks like the below

my-api
 - server
   - main.go
 - Dockerfile
 - docker-compose.yml
 - Makefile

This is the error I am getting:

go build github.com/firstApi/test-platform/lib/my-api/server: build output "server" already exists and is a directory

This is what my dockerfile looks like

FROM golang:1.12-stretch

ENV GO111MODULE=on
WORKDIR /go/src

COPY go.mod .
COPY go.sum .
RUN go mod download

COPY . .

RUN ["go", "get", "github.com/githubnemo/CompileDaemon"]

RUN go test ./... \
&& CGO_ENABLED=0 go build -v -a -installsuffix cgo -o /main server/main.go

ENTRYPOINT CompileDaemon -log-prefix=false -build="go build ./server" -command="./main"

any ideas what I am doing wrong and what I need to change in order to fix this issue?

UPDATE*****

I tried the solution as suggested by the only answer but I now get the following error:

Could not start command:%!(EXTRA *errors.errorString=can't start command: fork/exec ./server: permission denied)
over 4 years ago · Santiago Trujillo
1 answers
Answer question

0

Your default go build is attempting to output the same name as the directory. You could change your build and ENTRYPOINT line to refer to "go build -o apiserver".

over 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!